function handleFileSelect(event) {
	const $parentDom = $(event.target).parent().siblings('input')

	if ($parentDom.length < 1) {
		swal('检查dom元素是否正常', '', 'info')
		return
	}

	const file = event.target.files[0]

	if (!file) {
		swal('请先选择一个文件', '', 'info')
		return
	}

	$parentDom.val('文件上传中...')
	$parentDom.attr('readonly', true)

	let formData = new FormData()
	formData.append('image', file)

	$.ajax({
		url: '/api/uploads/pic',
		type: 'POST',
		data: formData,
		processData: false,
		contentType: false,
		success: function (response) {
			const { msg, data, code } = response
			if (code !== 200) {
				$parentDom.val('')
				$parentDom.removeAttr('readonly')
				swal(msg, '', 'error')
				return
			}
			const { path, fileName } = data
			$parentDom.val(path + '/' + fileName)
			$parentDom.removeAttr('readonly')
			swal(msg, '', 'success')
		},
		error: function (jqXHR) {
			swal(jqXHR.responseJSON.msg, '', jqXHR.responseJSON.code !== 500 ? 'info' : 'erroe')
		}
	})
}

function handleFileSelectVideo(event) {
	const $parentDom = $(event.target).parent().siblings('input')

	if ($parentDom.length < 1) {
		swal('检查dom元素是否正常', '', 'info')
		return
	}

	const file = event.target.files[0]

	if (!file) {
		swal('请先选择一个文件', '', 'info')
		return
	}

	$parentDom.val('文件上传中...')
	$parentDom.attr('readonly', true)

	let formData = new FormData()
	formData.append('video', file)

	$.ajax({
		url: '/api/uploads/video',
		type: 'POST',
		data: formData,
		processData: false,
		contentType: false,
		success: function (response) {
			const { msg, data, code } = response
			if (code !== 200) {
				$parentDom.val('')
				$parentDom.removeAttr('readonly')
				swal(msg, '', 'error')
				return
			}
			const { path, fileName } = data
			$parentDom.val(path + '/' + fileName)
			$parentDom.removeAttr('readonly')
			swal(msg, '', 'success')
		},
		error: function (jqXHR) {
			swal(jqXHR.responseJSON.msg, '', jqXHR.responseJSON.code !== 500 ? 'info' : 'erroe')
		}
	})
}